//
//  MKUIPickerViewCellView.m
//  MKUI
//
//  Created by sushangjin on 15/6/18.
//  Copyright (c) 2015年 sushangjin. All rights reserved.
//

#import "MKUIPickerViewCellView.h"
#import "UIColor+MKUI.h"
@interface MKUIPickerViewCellView()
@property(nonatomic,strong) UIView *contentView;
@end

@implementation MKUIPickerViewCellView
+ (UIEdgeInsets)contentInsets{
	UIEdgeInsets insets = UIEdgeInsetsMake(0, 5, 0, 5);
	return insets;
}
- (id)initWithFrame:(CGRect)frame{
	if(self=[super initWithFrame:frame]){
        self.contentView = [[UIView alloc] init];
        [self addSubview:self.contentView];
        //
		self.titleLabel = [[UILabel alloc] init];
        
		self.titleLabel.textAlignment = NSTextAlignmentCenter;
		self.titleLabel.font = [UIFont systemFontOfSize:23.5];
        self.titleLabel.textColor = [UIColor mk_colorWithLight:UIColor.blackColor dark:UIColor.whiteColor];
		[self.contentView addSubview:self.titleLabel];
	}
	return self;
}
- (void)layoutSubviews{
	[super layoutSubviews];
	CGRect bounds = self.bounds;
    //适配iphoneX
    if(@available(iOS 11.0,*)){
        bounds = self.safeAreaLayoutGuide.layoutFrame;
    }
    self.contentView.frame = bounds;
    
	UIEdgeInsets insets = [self.class contentInsets];
	CGRect f1 = UIEdgeInsetsInsetRect(bounds, insets);
	self.titleLabel.frame = f1;
}

- (void)customReloadCellModel{
	if(self.cellModel.attributedTitle){
		self.titleLabel.text = nil;
		self.titleLabel.attributedText = self.cellModel.attributedTitle;
	}else{
		self.titleLabel.attributedText = nil;
		self.titleLabel.text = self.cellModel.title;
	}
}
@end
